﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 第二次作业
{
    public delegate void BigMoneyFetched();
    public class Account
    {
        private int id;
        private string code;
        private double money;

        public int getId()
        {
            return id;
        }
        public void setId(int id)
        {
            this.id = id;
        }

        public string getCode()
        {
            return code;
        }
        public void setCode(string code)
        {
            this.code = code;
        }

        public double getMoney()
        {
            return money;
        }

        public void setMoney(double money)
        {
            this.money = money;
        }

        public void deposite(double money)
        {
            this.money += money;
            MessageBox.Show("操作成功");
        }

        public void withdrow(double money)
        {
            if(this.money < money)
            {
                //提示金额不足
                MessageBox.Show("卡内余额不足");
            }
            else
            {
                EventFunction eventFunction = new EventFunction();
                involeDefine involeDefine = new involeDefine();
                if(money > 10000)
                {
                    involeDefine.moneyevent += eventFunction.BigMoney;
                    involeDefine.invoke();
                }
                this.money -= money;
                MessageBox.Show("操作成功");
            }
        }
    }

    class involeDefine
    {
        public event BigMoneyFetched moneyevent;

        public void invoke()
        {
            moneyevent?.Invoke();
        }
    }

    class EventFunction
    {
        public void BigMoney()
        {
            MessageBox.Show("取出金额大于10000，请确认");
        }
    }
}
